package com.realgodo.site.web.admin.show;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springside.modules.orm.Page;

import com.realgodo.site.entity.application.show.Show;
import com.realgodo.site.service.application.ShowManager;
import com.realgodo.site.web.admin.AdminDefaultController;

@Scope("prototype")
@Results( { @Result(name = "toindex", type = "redirect", location = "${base}/admin/show/") })
public class IndexController extends AdminDefaultController {

	private static final long serialVersionUID = -1943500061962534389L;

	@Autowired
	private ShowManager showManager;

	private Page<Show> showPage = new Page<Show>(PAGE_SIZE);
	private Show showForm = new Show();

	public String execute() throws Exception {
		showForm.setTop(Show.TOP_ALL);
		showForm.setViedo(Show.VIEDO_ALL);
		showPage
				.setPageNo(showManager.isParamNotNull(getParamMap(), Page.PAGE) ? Integer
						.valueOf((String) showManager.getParamValue(
								getParamMap(), Page.PAGE))
						: 1);// 查询页数
		showPage = this.showManager.findShows(showPage, showForm);
		super.setPageInfo(showPage);
		return SUCCESS;
	}

	public String top() {
		if (null != getId()) {
			this.showManager.topShow(getId());
		}
		return "toindex";
	}

	public String untop() {
		if (null != getId()) {
			this.showManager.untopShow(getId());
		}
		return "toindex";
	}

	public String viedotop() {
		if (null != getId()) {
			this.showManager.topViedo(getId());
		}
		return "toindex";
	}

	public String unviedotop() {
		if (null != getId()) {
			this.showManager.untopViedo(getId());
		}
		return "toindex";
	}

	public Page<Show> getShowPage() {
		return showPage;
	}

	public void setShowPage(Page<Show> showPage) {
		this.showPage = showPage;
	}

	public Show getShowForm() {
		return showForm;
	}

	public void setShowForm(Show showForm) {
		this.showForm = showForm;
	}

}
